package com.vancouver.knows.ui.fragment.homePage.carousel;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.squareup.picasso.Picasso;
import com.vancouver.knows.R;
import com.vancouver.knows.util.AppUtils;

/**
 * ImageView创建工厂
 */
public class ViewFactory {

	/**
	 * 获取ImageView视图的同时加载显示url
	 * 
	 * @return
	 */
	public static ImageView getImageView(Context context, String url) {
		ImageView imageView = (ImageView)LayoutInflater.from(context).inflate(
				R.layout.view_banner, null);
		if (url == null || url.equals("")){
			imageView.setBackgroundResource(R.drawable.no_image);
		}else{
			Glide.with(context)
					.load(url)
					.placeholder(R.drawable.no_image)
					.into(imageView);//.resize(AppUtils.getWindowWidth(context), 0)
		}
		return imageView;
	}
}
